<%@page import="com.scrum.Object.User"%>
<%@page import="com.scrum.Object.Post"%>
<%@page import="java.util.Vector"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Manage Post (User)</title>
<link href="../css/bootstrap-theme.min.css" rel="stylesheet"
	type="text/css" />
<link href="../css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="../css/post_style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
<script type="text/javascript" src="../js/ckeditor.js"></script>
<style>
.boder-from {
 border: 1px solid #FFFF;
 
}
</style>
</head>
<body>
    <div class="navbar">
      <!-- Wrap the .navbar in .container to center it within the absolutely positioned parent. -->
      <!-- <div class="container"> -->

        <!-- <a class="brand" href="#"><img src="assets/img/logo.png" width='80px' height='75px'></a> -->
        <div class="navbar navbar-default">
          <div class="navbar-inner-top">
            <div class="container">
            <!-- Responsive Navbar Part 1: Button for triggering responsive navbar (not covered in tutorial). Include responsive CSS to utilize. -->
            <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
            <!-- Responsive Navbar Part 2: Place all navbar contents you want collapsed withing .navbar-collapse.collapse. -->
            <a class="brand" href="#"></a>
            <div class="nav-collapse collapse">
              <ul class="nav">
                <!-- <li class="active"><a href="#">Home</a></li> -->
                <!-- Read about Bootstrap dropdowns at http://twbs.github.com/bootstrap/javascript.html#dropdowns -->
             
            </div><!--/.nav-collapse -->
            </div>
          </div><!-- /.navbar-inner -->
        </div><!-- /.navbar -->

      <!-- </div> /.container -->
      <div class="navbar navbar-inverse">
        <div class="navbar-inner">
          <div class="container">
            <div class="nav-collapse collapse">
              <ul class="nav">
                <li ><a href="#restaurants">Manager user</a></li>
                <li class="current"><a href="#recipes">Manager post</a></li>
                <li><a href="#about">Back home</a></li>
              </ul>
              <p class="navbar-form navbar-right right">
                <label class="active"></label>  
                <a href="#"> Administrator</a> | <a href="#">Logout</a>
               </p>
            </div>
          </div>
        </div>
      </div>
    </div><!-- /.navbar-wrapper -->
		 <div class="container">   
		 <div class="content">
		<h3 style="font-family: Helvetica Neue, Helvetica, Arial, sans-serif;color: #0088cc;margin-left: 300px">User manage post</h3> 
		<hr>       
		
		<form id="search" method="get" action="">
				 <input type="text" class="form-control style-search" name="search"/>
				 <button type="submit" class="btn btn-primary">Search</button>
			</form>                             
	      <table class="table table-striped table-bordered table-hover table-condensed" >
		        <thead>
		          <tr>
		            <th>Index</th>
		            <th>Title</th>
		            <th>Image</th>
		            <th>Post Time</th>
		            <th>Done</th>
		            
		          </tr>
		        </thead>
		        
		        <%
		        
			 	String search = request.getParameter("search");
		        int user_id = ((User)session.getAttribute("currentuser")).getId();
				Vector<Post> post_list;
				Post post = null;
				String filePath;
				if (search == null){
					post_list = Post.getAllPostByUserId(user_id);
				}else{
					post_list = Post.getAllPostByTitleUserId(user_id, search);
				}
				%>
		        <tbody>
		        <%
						for (int i = 0; i < post_list.size(); i++) {
							post = post_list.get(i);
							filePath = "../post/image/" + post.getImage();
					%>
		          <tr class="warning">
		            <td width="5px"><%=i + 1%></td>
						<td width="40px"><%=post.getTitle()%></td>
						<td width="40px"><img alt="" src="<%=filePath%>" height="150" width="150" /></td>
		            <td width="40px"><%= post.getPost_time() %></td>
		            <td width="100px">
		           	<a type="button" role="button" class="btn btn-primary" href="viewpost.jsp?postid=<%=post.getId()%>">View</a>
		            <a type="button"  role="button" class="btn btn-success" href="updatepost.jsp?postid=<%=post.getId()%>">Edit</a>
    				<a type="button" role="button" class="btn btn-danger" href="deletepost?postid=<%=post.getId()%>">Delete</a>
    				 </td>
		          </tr>
		          <% } %>
		         </tbody>
	      </table>
    </div>
    </div>
	
</body>
</html>
		      
		